package com.cf.domain.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.cf.utils.DateUtil;
import lombok.Data;
import org.thymeleaf.util.DateUtils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

/**
 * @Author lzqinga@126.com
 * @Date 2024/11/14  10:58
 */
@Data
@TableName("t_news")
public class News {

    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    private String title;

    private String author;

    private String images;

    private Integer type;

    private String content;

    @TableField("create_time")
    private Date createTime;

    //标记，是否在首页显示
    private Integer flag;

    private Integer enable;

    public String getTypeName(){
        if(this.type == 1){
            return "新闻";
        }else if(this.type == 2){
            return "通知";
        }else if(this.type == 3){
            return "动态";
        }
        return "未知";
    }

    public String getCreateTimeName(){
        return DateUtil.date2Str(this.createTime, DateUtil.YYYYMMDDHHMMSS);
    }

    public String getCreateTimeName1(){
        return DateUtil.date2Str(this.createTime, DateUtil.YYYYMMDD);
    }
}
